<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>打印数字</title>
</head>
<body>
  
    <script>
   
    var timer = function(){
        var i =0;
        var abc = setInterval(function(){
              if(i==10){
                clearInterval(abc)
            }
            console.log(i);
            i++
          
        },1000)
    }
    timer()

    </script>
</body>
</html>